using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Daniel.Core.Models.Mapping
{
    public class Product_SpecificationAttribute_MappingMap : EntityTypeConfiguration<Product_SpecificationAttribute_Mapping>
    {
        public Product_SpecificationAttribute_MappingMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.CustomValue)
                .HasMaxLength(4000);

            // Table & Column Mappings
            this.ToTable("Product_SpecificationAttribute_Mapping");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.ProductId).HasColumnName("ProductId");
            this.Property(t => t.SpecificationAttributeOptionId).HasColumnName("SpecificationAttributeOptionId");
            this.Property(t => t.CustomValue).HasColumnName("CustomValue");
            this.Property(t => t.AllowFiltering).HasColumnName("AllowFiltering");
            this.Property(t => t.ShowOnProductPage).HasColumnName("ShowOnProductPage");
            this.Property(t => t.DisplayOrder).HasColumnName("DisplayOrder");

            // Relationships
            this.HasRequired(t => t.Product)
                .WithMany(t => t.Product_SpecificationAttribute_Mapping)
                .HasForeignKey(d => d.ProductId);
            this.HasRequired(t => t.SpecificationAttributeOption)
                .WithMany(t => t.Product_SpecificationAttribute_Mapping)
                .HasForeignKey(d => d.SpecificationAttributeOptionId);

        }
    }
}
